var userMess="";
$(function(){
    //获取用户信息
    getUser();
    userMess=JSON.stringify(ym.user);
    //通过用户信息去换取相应信息
    getUsers();
})
function pageJump(num){
    if(num==1){
        window.location.href="index.html";
    }else if(num==2){
        window.location.href="car.html";
    }
}
/*获取用户信息*/
function getUsers(){
    ym.ajax({
        url : "/shop/order/user",
        type : "post",
        param:{
            ymUser:userMess,
        },
        success : function(data) {
            $(".myIntegralNum span").html(data.obj.point);
            $(".userHeadImg").attr("src",data.obj.pic);
            $(".personName").html(data.obj.name);
        }
    })
    getOrderNum();
}
/*获取订单数量*/
function getOrderNum(){
    ym.ajax({
        url : "/shop/order/getCont",
        type : "post",
        param:{
            ymUser:userMess,
        },
        success : function(data) {
            if(data.obj!=null){
                if(data.obj.pendingPayment!=undefined||data.obj.pendingPayment!=null){
                    if(data.obj.pendingPayment>99){
                        data.obj.pendingPayment="..."
                    }
                    $(".pendingPayment").html(data.obj.pendingPayment);
                    $(".pendingPayment").removeClass("hide");
                }
                if(data.obj.pendingDelivery!=undefined||data.obj.pendingDelivery!=null){
                    if(data.obj.pendingDelivery>99){
                        data.obj.pendingDelivery="..."
                    }
                    $(".pendingDelivery").html(data.obj.pendingDelivery);
                    $(".pendingDelivery").removeClass("hide");
                }
                if(data.obj.pendingGoods!=undefined||data.obj.pendingGoods!=null){
                    if(data.obj.pendingGoods>99){
                        data.obj.pendingGoods="..."
                    }
                    $(".pendingGoods").html(data.obj.pendingGoods);
                    $(".pendingGoods").removeClass("hide");
                }
                if(data.obj.theEnd!=undefined||data.obj.theEnd!=null){
                    if(data.obj.theEnd>99){
                        data.obj.theEnd="..."
                    }
                    $(".theEnd").html(data.obj.theEnd);
                    $(".theEnd").removeClass("hide");
                }
            }
        }
    })
}
/*跳转订单页面*/
function jumpOrder(num){
     window.location.href="order.html?orderState="+num;
}
/*跳转购物车页面*/
function jumpCar(){
    window.location.href="car.html";
}
/*跳转地址页面*/
function jumpAddr(){
    window.location.href="address.html";
}
